﻿using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MRSite.Cache.Configuration
{
    public class CacheConfiguration : ICacheConfiguration
    {
        private readonly List<IConfigurationItem> _configurationItems;
        public CacheConfiguration()
        {
            _configurationItems = new List<IConfigurationItem>();
        }

        public IReadOnlyList<IConfigurationItem> ConfigurationItems
        {
            get { return _configurationItems.ToImmutableList(); }
        }

        public void ConfigureAllCache(Action<ICache> actionInit)
        {
            _configurationItems.Add(new ConfigurationItem(actionInit));
        }

        public void ConfigureOneCache(string cacheName, Action<ICache> actionInit)
        {
            _configurationItems.Add(new ConfigurationItem(cacheName, actionInit));
        }
    }
}
